<template>
  <view>
    <u-navbar title="病情自检" :is-back="false" back-icon-size="34" title-size="36" :border-bottom="false" :background="background" title-color="#222" back-icon-color="#222">
      <view class="slot-wrap" style="font-size: 24rpx; padding-right: 28rpx; color: #1a9eff; margin-left: 30rpx" @tap="add">新增自检</view>
    </u-navbar>
    <scroll-view scroll-y="true" id="box" :style="{ height: boxHeight + 'px' }" @scrolltolower="getList">
      <view class="" style="margin: 20rpx 28rpx; background: #fff; border-radius: 12rpx; padding-bottom: 41rpx" v-for="(i, k) in list" :key="k" @tap="myusers(i.id)">
        <view class="" style="display: flex; align-items: center; justify-content: space-between; padding: 32rpx 33rpx">
          <view class="" style="font-size: 26rpx">病情自检</view>
          <view class="" style="font-size: 24rpx; color: #666666" v-if="i.status == 2">医生已回复</view>
        </view>
        <view class="" style="display: flex; align-items: center; justify-content: space-between; padding: 0 32rpx">
          <view class="">
            <view class="" style="font-size: 30rpx">
              {{ i.patient_name }}
            </view>
            <view class="" style="font-size: 24rpx; color: #999999; padding-top: 15rpx">
              {{ i.create_time_text }}
            </view>
          </view>
          <image :src="img_url + i.images[0]" mode="aspectFill" style="width: 122rpx; height: 122rpx; border-radius: 20rpx"></image>
        </view>
      </view>
    </scroll-view>
  </view>
</template>

<script>
export default {
  data() {
    return {
      background: {
        background: '#FFFFFF'
      },
      boxHeight: '',
      page: 1,
      list: []
    };
  },
  onReady() {
    this.box();
  },
  onShow() {
    this.getList(1);
  },
  methods: {
    myusers(e) {
      uni.navigateTo({
        url: '/pages/slow/self_detail?id=' + e
      });
    },
    add() {
      uni.navigateTo({
        url: '/home/selfinspection/selfinspection'
      });
    },
    box() {
      const query = uni.createSelectorQuery().in(this);
      query
        .select('#box')
        .boundingClientRect((data) => {
          this.boxHeight = this.screenHeight - data.top - 50;
        })
        .exec();
    },
    getList(e) {
      if (e == 1) {
        this.list = [];
        this.page = 1;
      }
      this.api({
        url: '/api//healthy/getCheckList',
        method: 'post',
        data: {
          page: this.page
        }
      }).then((res) => {
        this.list = this.list.concat(res.data);
        this.page++;
      });
    }
    // api//healthy/getCheckList
  }
};
</script>

<style>
page {
  background: #f8f8f8;
}
</style>
